<template>
  <view class="login-container">
    <view class="login-box">
      <text class="login-title">登录</text>
      <view class="input-item">
        <input class="input-field" type="text" placeholder="请输入用户名" v-model="username" />
      </view>
      <view class="input-item">
        <input class="input-field" type="password" placeholder="请输入密码" v-model="password" />
      </view>
      <navigator url="/pages/tabBar/CardViewPage/CardViewPage" open-type="switchTab">
		  <button class="login-button" @click="login">登录</button></navigator>
      <view class="register-link">
        <text>没有账号？</text>
        <text class="register-text" @click="goDetailPage('regist')">去注册</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {

    };
  },
  onload(){
	  console.log("tabcomPage--->onLoad");
  },
  methods: {
    login() {
      if (!this.username) {
        uni.showToast({
          title: '请输入用户名',
          icon: 'none'
        });
        return;
      }
      if (!this.password) {
        uni.showToast({
          title: '请输入密码',
          icon: 'none'
        });
        return;
      }
      uni.showToast({
        title: '登录成功',
        icon: 'success',
		duration:1500,
      });
    },
    goDetailPage(e) {
        if (typeof e === 'string') {
            uni.navigateTo({
    			url: '/pages/' + e + '/' + e
                });
        } else {
            uni.navigateTo({
                url: e.url
            });
        }
    },
	
  }
};
</script>

<style>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #fff;
}

.login-box {
  width: 80%;
  padding: 20px;
  background-color: #f5f5f5;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.login-title {
  display: block;
  text-align: center;
  font-size: 20px;
  margin-bottom: 20px;
}

.input-item {
  margin-bottom: 15px;
}

.input-field {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
}

.login-button {
  height: 40px;
  background-color: #007AFF;
  color: white;
  border: none;
  border-radius: 5px;
  margin-top: 10px;
}

.register-link {
  text-align: center;
  margin-top: 10px;
}

.register-text {
  color: #007AFF;
}
</style>